<?php

namespace App\Http\Controllers\Client;

use Biz\Requests\Auth\LoginRequest;
use Biz\Resources\User\UserResource;
use Biz\Services\User\UserClientService;

/**
 * LoginController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class LoginController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * RepositoryController constructor.
     *
     * @param UserClientService $service
     */
    public function __construct(UserClientService $service)
    {
        $this->service = $service;
    }

    /**
     * Login.
     *
     * @param LoginRequest $request
     *
     * @return string
     */
    public function login(LoginRequest $request)
    {
        $userClient = $this->service->login($request->all());

        $user = $userClient->getUser();
        $user->setClient($userClient);

        return new UserResource($user);
    }
}
